package com.itheima.controller;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserController {

    @Test
    public  void test1() {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");

        UserService userService = (UserService)ctx.getBean("userService");
        userService.save();
    }
    @Test
    public  void test2() {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("spring.xml");

        UserDao userDao = (UserDao)ctx.getBean("userDao");
        userDao.say();
        ((ClassPathXmlApplicationContext) ctx).close();
    }
}
